package com.nuts.core.bean.request;

import java.net.URLDecoder;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import com.nuts.base.bean.request.BaseReqVO;
import com.nuts.base.utils.QEncodeUtil;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 用户
 * 
 * @author 陈皓
 * @date 2017年8月10日 下午3:33:36
 */
@Getter
@Setter
@ToString
@ApiModel("员工请求")
public class OAEmployeeReqVO extends BaseReqVO {

	@ApiModelProperty("工号")
	private String workId;
	
	@ApiModelProperty("工号编码")
	private String workIdCode;
	
	@ApiModelProperty("登录人工号")
	private String loginWorkId;
	
	@ApiModelProperty("姓名")
	private String employeeName;
	
	@ApiModelProperty("部门ID")
	private String deptId;
	private String departmentId;

	@ApiModelProperty("手机号码")
	private String mobilePhone;

	@ApiModelProperty("用户类型")
	private String customerType;
	
	@ApiModelProperty("邮箱")
	private String workEmail;

	public void setWorkIdCode(String workIdCode) throws Exception {
		ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
		HttpServletRequest request = attributes.getRequest();
		String workId = request.getHeader("workId");
		if (StringUtils.isBlank(workId)) {
			workId = QEncodeUtil.decrypt(URLDecoder.decode(workIdCode, "UTF-8"));
			this.workId = workId;
		} else {
			this.workId = workId;
		}
		this.workIdCode = workIdCode;
	}
}
